package model

import (
	"manager/model/entity"
)

// FirmwareCreateRequest 创建现场数据
type FirmwareCreateRequest struct {
	EbikeTypeId int64 `json:"ebike_type_id"`

	EbikeType string `json:"ebike_type"`

	Name string `json:"name"`

	Version string `json:"version"`

	Path string `json:"path"`

	ExecStatus int `json:"exec_status"`

	Desc string `json:"desc"`

	UpdatedAt int64 `json:"updated_at"`
}

// FirmwareUpdateRequest 更新现场数据
type FirmwareUpdateRequest struct {
	Id int64 `json:"id"`

	EbikeTypeId *int64 `json:"ebike_type_id"`

	EbikeType *string `json:"ebike_type"`

	Name *string `json:"name"`

	Version *string `json:"version"`

	Path *string `json:"path"`

	ExecStatus *int `json:"exec_status"`

	Desc *string `json:"desc"`

	CreatedAt int64 `json:"created_at"`

	UpdatedAt *int64 `json:"updated_at"`
}

// FirmwareListRequest 列表现场数据
type FirmwareListRequest struct {
	Index int `json:"index"`
	Size  int `json:"size"`

	Id int64 `json:"id"`

	EbikeTypeId *int64 `json:"ebike_type_id"`

	EbikeType *string `json:"ebike_type"`

	Name *string `json:"name"`

	Version *string `json:"version"`

	Path *string `json:"path"`

	ExecStatus *int `json:"exec_status"`

	Desc *string `json:"desc"`

	UpdatedAt *int64 `json:"updated_at"`
}

// FirmwareListResponse 列表回包数据
type FirmwareListResponse struct {
	Total int             `json:"total"`
	List  []*FirmwareInfo `json:"list"`
}

// FirmwareInfoRequest 列表现场数据
type FirmwareInfoRequest struct {
	Id int64 `json:"id"`

	EbikeTypeId *int64 `json:"ebike_type_id"`

	EbikeType *string `json:"ebike_type"`

	Name *string `json:"name"`

	Version *string `json:"version"`

	Path *string `json:"path"`

	ExecStatus *int `json:"exec_status"`

	Desc *string `json:"desc"`

	UpdatedAt *int64 `json:"updated_at"`
}

// FirmwareInfo 详细数据
type FirmwareInfo struct {
	Id int64 `json:"id"`

	EbikeTypeId int64 `json:"ebike_type_id"`

	EbikeType string `json:"ebike_type"`

	Name string `json:"name"`

	Version string `json:"version"`

	Path string `json:"path"`

	ExecStatus int `json:"exec_status"`

	Desc string `json:"desc"`

	CreatedAt int64 `json:"created_at"`

	UpdatedAt int64 `json:"updated_at"`
}

// FirmwareDeleteRequest 删除现场数据
type FirmwareDeleteRequest struct {
	Id int64 `json:"id"`
}

// FirmwaresEntityToDto entity数据转换
func FirmwaresEntityToDto(firmwares []*entity.Firmware) []*FirmwareInfo {
	out := make([]*FirmwareInfo, 0, len(firmwares))
	for _, c := range firmwares {
		out = append(out, FirmwareEntityToDto(c))
	}
	return out
}

// FirmwareEntityToDto entity数据转换
func FirmwareEntityToDto(e *entity.Firmware) *FirmwareInfo {
	return &FirmwareInfo{

		Id: e.Id,

		EbikeTypeId: e.EbikeTypeId,

		EbikeType: e.EbikeType,

		Name: e.Name,

		Version: e.Version,

		Path: e.Path,

		ExecStatus: e.ExecStatus,

		Desc: e.Desc,

		CreatedAt: e.CreatedAt,

		UpdatedAt: e.UpdatedAt,
	}
}
